﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.BLL;
using Maticsoft.Model;
using FineUI;

namespace EmptyProjectNet45_FineUI
{
    public partial class registry_teacher : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            if (tbxUserName.Text == "" || tbxPassword.Text == "" || tbxPasswordConfirm.Text == "" || tbxName.Text == "")
            {
                Alert.ShowInTop("请输入必要信息");
                return;
            }
            if (tbxPassword.Text != tbxPasswordConfirm.Text)
            {
                Alert.ShowInTop("两次密码不匹配");
                return;
            }

            Maticsoft.BLL.Teacher CurrentTeacher = new Maticsoft.BLL.Teacher();
            Maticsoft.Model.Teacher CurrentTeacherInfom = new Maticsoft.Model.Teacher();

            if (CurrentTeacher.Exists(tbxUserName.Text))
            {
                Alert.ShowInTop("您的用户名已经被注册，请重新输入");
                return;
            }

            CurrentTeacherInfom.T_Id = tbxUserName.Text;
            CurrentTeacherInfom.T_Password = tbxPassword.Text;
            CurrentTeacherInfom.T_Name = tbxName.Text;
            CurrentTeacherInfom.T_Sex = tbxSex.Text;
            CurrentTeacherInfom.T_Duty = tbxDuty.Text;
            CurrentTeacherInfom.T_Department = tbxDepartment.Text;
            CurrentTeacherInfom.T_Contact = tbxConnect.Text;
            CurrentTeacherInfom.T_Email = tbxEmail.Text;

            CurrentTeacher.Add(CurrentTeacherInfom);

            if (CurrentTeacher.Exists(tbxUserName.Text))
            {

                Response.Redirect("~/login.aspx");

            }
            else
            {
                Alert.ShowInTop("注册失败");
            }


        }
    }
}